package com.zsix.system.service.impl;

import com.zsix.common.dto.controllerParams.GroupUsersParams;
import com.zsix.common.entity.formComponents.FormSortEntity;
import com.zsix.common.util.StringUtils;
import com.zsix.system.mapper.UserInfoMapper;
import com.zsix.system.mapper.formComponentsMapper.FormSortEntityMapper;
import com.zsix.system.mapper.orgmanagementMapper.*;
import com.zsix.system.service.IOrgManagementService;
import com.zsix.system.service.manager.CommManager;
import com.zsix.common.common.BusinessException;
import com.zsix.common.dto.controllerParams.UserParams;
import com.zsix.common.dto.orgDto.SysRoleDept;
import com.zsix.common.dto.orgDto.SysRoleDto;
import com.zsix.common.dto.orgDto.SysRoleMenu;
import com.zsix.common.entity.UserInfo;
import com.zsix.common.entity.orgmanagement.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

@Service
public class OrgManagementServiceImpl implements IOrgManagementService {
    @Autowired
    private CompanyEntityMapper companyEntityMapper;
    @Autowired
    private DepartmentEntityMapper departmentEntityMapper;
    @Autowired
    private UserEntityMapper userEntityMapper;
    @Autowired
    private PasswordEncoder passwordEncoder;
    @Autowired
    private RolesEntityMapper rolesEntityMapper;
    @Autowired
    private PositionEntityMapper positionEntityMapper;
    @Autowired
    private GroupMapper groupMapper;
    @Autowired
    private UserGroupMapper userGroupMapper;
    @Autowired
    UserInfoMapper mapper;
    @Autowired
    private CommManager commManager;

    @Autowired
    private OrgGroupTypeEntityMapper orgGroupTypeEntityMapper;

    /**
     * 获取公司列表
     * @return
     */
    @Override
    public List<CompanyEntity> getCompanyList(){
        return getCompanyEntityList();
    }
    private List<CompanyEntity> getCompanyEntityList(){
        List<CompanyEntity> companyEntityList= companyEntityMapper.getCompanyList();
        //2、组装树形结构
        List<CompanyEntity> newList = companyEntityList.stream()
                .filter(t -> t.getParentid() == 0)
                .map((menu) -> {
                    menu.setChildren(this.getCompanyChildren(menu,companyEntityList));
                    return menu;
                })
                .collect(Collectors.toList());
        return newList;
    }
    /**
     * 增加公司
     * @param companyEntity
     * @return
     */
    @Override
    public String addCompany(CompanyEntity companyEntity){
        companyEntityMapper.addCompany(companyEntity);
        return "添加成功";
    }
    /**
     * 修改公司信息
     * @param companyEntity
     * @return
     */
    @Override
    public String updateCompany(CompanyEntity companyEntity){
        companyEntityMapper.updateCompany(companyEntity);
        return "修改成功";
    }
    /**
     * 删除公司信息
     * @param companyEntity
     * @return
     */
    @Override
    public String deleteCompany(CompanyEntity companyEntity){
        companyEntityMapper.deleteCompany(companyEntity);

        return "删除成功。";
    }
    /**
     * 递归查找当前公司的子公司
     * @param root 单个对象
     * @param all 所有的集合
     * @return 排序后的子类
     */
    private List<CompanyEntity> getCompanyChildren(CompanyEntity root,List<CompanyEntity> all){
        List<CompanyEntity> childrenList = all.stream()
                .filter(t -> t.getParentid() == root.getId())
                .map(g -> {
                    //找子菜单
                    g.setChildren(getCompanyChildren(g,all));
                    return g;
                })
                //菜单排序
                .collect(Collectors.toList());

        return childrenList;
    }
    /**
     * 获取部门列表
     * @return
     */
    @Override
    public List<DepartmentEntity> getDepartmentList(DepartmentEntity departmentEntity){
        List<DepartmentEntity> departmentEntities = departmentEntityMapper.getDepartmentList(departmentEntity.getId(),
                departmentEntity.getName(), String.valueOf(departmentEntity.getCompanyid()));
        return departmentEntities;
    }

    /**
     * 获取部门人员
     * @return
     */
    @Override
    public List<UserEntity> getDeptUsers(DepartmentEntity departmentEntity){
        List<UserEntity> userList=userEntityMapper.getUserByDepartId(departmentEntity.getId());
        return userList;
    }
    @Override
    public List<UserEntity> getDeptUserTree(){
        List<UserEntity> userList=userEntityMapper.getDeptUsers();;
        //2、组装树形结构
        List<UserEntity> newList = userList.stream()
                .filter(t -> t.getDepartid().equals("0"))
                .map((menu) -> {
                    menu.setChildren(commManager.getUserChildren(menu,userList));
                    return menu;
                })
                .collect(Collectors.toList());
        return newList;
    }

    /**
     * 获取公司下的部门
     * @param companyId
     * @return
     */
    @Override
    public List<DepartmentEntity> getDeptByCompany(Integer companyId){
        return getDepartmentEntityListByCompany(companyId);
    }
    private List<DepartmentEntity> getDepartmentEntityListByCompany(Integer companyId){
        List<DepartmentEntity> departmentList= departmentEntityMapper.getDeptByCompany(companyId);
        //2、组装树形结构
        List<DepartmentEntity> newList = departmentList.stream()
                .filter(t -> t.getParentid().equals("0"))
                .map((menu) -> {
                    menu.setChildren(commManager.getDeptChildren(menu,departmentList));
                    return menu;
                })
                .collect(Collectors.toList());
        return newList;
    }

    /**
     * 获取部门树
     * @return
     */
    @Override
    public List<DepartmentEntity> getDepartmentEntityList(){
        List<DepartmentEntity> departmentList= departmentEntityMapper.getDepartmentList("","","");
        //2、组装树形结构
        List<DepartmentEntity> newList = departmentList.stream()
                .filter(t -> t.getParentid().equals("0"))
                .map((menu) -> {
                    menu.setChildren(commManager.getDeptChildren(menu,departmentList));
                    return menu;
                })
                .collect(Collectors.toList());
        return newList;
    }
    private List<UserEntity> getUserList(){
        List<UserEntity> userList=userEntityMapper.getDeptUsers();;
        //2、组装树形结构
        List<UserEntity> newList = userList.stream()
                .filter(t -> t.getDepartid().equals("0"))
                .map((menu) -> {
                    menu.setChildren(commManager.getUserChildren(menu,userList));
                    return menu;
                })
                .collect(Collectors.toList());
        return newList;
    }
    /**
     * 增加部门
     * @param departmentEntity
     * @return
     */
    @Override
    public String addDepartment(DepartmentEntity departmentEntity){
        departmentEntity.setId(UUID.randomUUID().toString());
        departmentEntityMapper.addDepartment(departmentEntity);
        return "添加成功";
    }
    /**
     * 修改部门
     * @param departmentEntity
     * @return
     */
    @Override
    public String updateDepartment(DepartmentEntity departmentEntity){
        departmentEntityMapper.updateDepartment(departmentEntity);
        return "修改成功";
    }
    /**
     * 删除部门
     * @param departmentEntity
     * @return
     */
    @Override
    public String deleteDepartment(DepartmentEntity departmentEntity){
        departmentEntityMapper.deleteDepartment(departmentEntity);
        return "删除成功";
    }
    /**
     * 设置部门负责人
     * @param departmentEntity
     * @return
     */
    @Override
    public String setDepartmentManager(DepartmentEntity departmentEntity){
        departmentEntityMapper.setDepartmentManager(departmentEntity);
        return "设置成功";
    }
    /**
     * 设置部门分管领导
     * @param departmentEntity
     * @return
     */
    @Override
    public String setDepartmentLeader(DepartmentEntity departmentEntity){
        departmentEntityMapper.setDepartmentLeader(departmentEntity);
        return "设置成功";
    }
    /**
     * 设置所属公司
     * @param departmentEntity
     * @return
     */
    @Override
    public String updateDeptCompany(DepartmentEntity departmentEntity){
        departmentEntityMapper.updateDeptCompany(departmentEntity);
        return "设置成功";
    }
    /**
     * 获取组织结构数据
     * @return
     */
    @Override
    public HashMap<String,Object> getOrgData(){
        List<DepartmentEntity> departmentList=getDepartmentEntityList();
        List<UserEntity> userEntityList=userEntityMapper.getUserEntityList("","","");
        List<RolesEntity> rolesEntities=rolesEntityMapper.rolesList("");
        List<PositionEntity> positionEntities=positionEntityMapper.positionList("");
        List<CompanyEntity> companyEntities=getCompanyEntityList();
        List<GroupEntity> groupEntityList=groupMapper.getGroupList("");
        HashMap<String,Object> hashMap=new HashMap<>();

        hashMap.put("departList",departmentList);
        hashMap.put("userList",userEntityList);
        hashMap.put("rolesList",rolesEntities);
        hashMap.put("positionList",positionEntities);
        hashMap.put("companyList",companyEntities);
        hashMap.put("groupEntityList",groupEntityList);

        return hashMap;
    }
    /**
     * 获取岗位列表
     * @param positionEntity
     * @return
     */
    @Override
    public List<PositionEntity> positionListPage(PositionEntity positionEntity){
        List<PositionEntity> positionEntities=positionEntityMapper.positionList(positionEntity.getName());
        return positionEntities;
    }

    /**
     * 获取用户的岗位
     * @param username
     * @return
     */
    @Override
    public List<PositionEntity> positionListByUser(String username){
        return positionEntityMapper.positionListByUser(username);
    }
    /**
     * 获取岗位成员
     * @param positionEntity
     * @return
     */
    @Override
    public List<UserEntity> getPositionUser(PositionEntity positionEntity){
        List<UserEntity> userEntities=userEntityMapper.getUserByPositionId(positionEntity.getId());
        return userEntities;
    }
    /**
     * 增加岗位
     * @param positionEntity
     */
    @Override
    public String addPosition(PositionEntity positionEntity){
        positionEntity.setId(UUID.randomUUID().toString());
        positionEntityMapper.addPosition(positionEntity);
        return "添加成功";
    }

    /**
     * 更新岗位信息
     * @param positionEntity
     * @return
     */
    @Override
    public String updatePosition(PositionEntity positionEntity){
        positionEntityMapper.updatePosition(positionEntity);
        return "更新成功";
    }

    /**
     * 删除岗位
     * @param positionEntity
     * @return
     */
    @Override
    public String deletePosition(PositionEntity positionEntity){
        positionEntityMapper.deletePosition(positionEntity.getId());
        return "删除成功";
    }

    /**
     * 删除用户的岗位
     * @param username
     * @return
     */
    @Override
    public String deletePositionUser(String username){
        positionEntityMapper.deletePositionUser(username);
        return "删除成功";
    }

    /**
     * 获取角色列表
     * @return
     */
    @Override
    public List<RolesEntity> rolesList(){
        return rolesEntityMapper.rolesList("");
    }

    /**
     * 角色部门
     * @param id
     * @return
     */
    @Override
    public List<SysRoleDept> roleDeptTreeselect(String id){
        return rolesEntityMapper.roleDeptTreeselect(id);
    }
    /**
     * 获取角色列表分页
     * @param roles
     * @return
     */
    @Override
    public List<RolesEntity> rolesListPage(RolesEntity roles){
        List<RolesEntity> rolesEntities=rolesEntityMapper.rolesList(roles.getName());
        return  rolesEntities;
    }

    /**
     * 获取用户的角色
     * @param username
     * @return
     */
    @Override
    public List<RolesEntity> rolesListByUser(String username){
        return rolesEntityMapper.rolesListByUser(username);
    }

    /**
     * 获取角色成员
     * @param roles
     * @return
     */
    @Override
    public List<UserEntity> getRoleUsers(RolesEntity roles){
        List<UserEntity> userEntities=userEntityMapper.getUserByRoleId(roles.getId());
        return userEntities;
    }
    /**
     * 增加角色
     * @param sysRoleDto
     * @return
     */
    @Override
    public String addRoles(SysRoleDto sysRoleDto){
        RolesEntity rolesEntity=new RolesEntity();
        rolesEntity.setId(UUID.randomUUID().toString());
        rolesEntity.setName(sysRoleDto.getName());
        rolesEntityMapper.addRoles(rolesEntity);
        return insertRoleMenu(sysRoleDto);
    }

    /**
     * 修改角色信息
     * @param sysRoleDto
     * @return
     */
    @Override
    public String updateRoles(SysRoleDto sysRoleDto){
        RolesEntity rolesEntity=new RolesEntity();
        rolesEntity.setId(sysRoleDto.getId());
        rolesEntity.setName(sysRoleDto.getName());
        rolesEntity.setData_scope(sysRoleDto.getDataScope());
        rolesEntityMapper.updateRoles(rolesEntity);
        insertRoleMenu(sysRoleDto);
        setDataScope(sysRoleDto);
        return "修改成功";
    }

    /**
     * 更新角色菜单
     * @param sysRoleDto
     * @return
     */
    public String insertRoleMenu(SysRoleDto sysRoleDto){
        List<SysRoleMenu> sysRoleMenus=new ArrayList<SysRoleMenu>();
        for (String menuId: sysRoleDto.getMenuIds()){
            SysRoleMenu sysRoleMenu=new SysRoleMenu();
            sysRoleMenu.setMenuId(menuId);
            sysRoleMenu.setRoleId(sysRoleDto.getId());
            sysRoleMenus.add(sysRoleMenu);
        }
        if(sysRoleMenus.size()>0){
            rolesEntityMapper.deleteRoleMenu(sysRoleDto.getId());
            rolesEntityMapper.batchRoleMenu(sysRoleMenus);
        }
        return "修改成功";
    }

    /**
     * 设置数据权限
     * @param sysRoleDto
     * @return
     */
    public String setDataScope(SysRoleDto sysRoleDto){
        List<SysRoleDept> sysRoleDepts=new ArrayList<SysRoleDept>();
        for (String deptId: sysRoleDto.getDepts()){
            SysRoleDept sysRoleDept=new SysRoleDept();
            sysRoleDept.setDept_Id(deptId);
            sysRoleDept.setRole_Id(sysRoleDto.getId());
            sysRoleDepts.add(sysRoleDept);
        }
        if(sysRoleDepts.size()>0){
            rolesEntityMapper.deleteDataScope(sysRoleDto.getId());
            rolesEntityMapper.batchRoleDept(sysRoleDepts);
        }
        return "修改成功";
    }

    /**
     * 删除角色
     * @param sysRoleDto
     * @return
     */
    @Override
    public String deleteRoles(SysRoleDto sysRoleDto){
        rolesEntityMapper.deleteRoles(sysRoleDto.getId());
        rolesEntityMapper.deleteRoleMenu(sysRoleDto.getId());
        return "删除成功";
    }

    /**
     * 删除用户的角色
     * @param username
     * @return
     */
    @Override
    public String deleteRoleUser(String username){
        rolesEntityMapper.deleteRoleUser(username);
        return "删除成功";
    }

    /**
     * 获取人员列表分页
     * @param user
     * @return
     */
    @Override
    public List<UserEntity> getUserList(UserEntity user){
        List<UserEntity> userEntityList =
                userEntityMapper.getUserEntityList(user.getName(), user.getUsername()
                        , String.valueOf(user.getDepartid()));
        return userEntityList;
    }

    /**
     * 获取人员详细信息
     * @param username
     * @return
     */
    @Override
    public HashMap<String,Object> getUserEntity(String username){
        HashMap<String,Object> hashMap=new HashMap<>();
        try {
            UserEntity userEntityInfo = userEntityMapper.getUserEntityInfo(username);
            List<PositionEntity> positionEntities=positionEntityMapper.positionListByUser(username);
            List<RolesEntity> rolesEntities=rolesEntityMapper.rolesListByUser(username);
            hashMap.put("user",userEntityInfo);
            hashMap.put("positions",positionEntities);
            hashMap.put("roles",rolesEntities);
            return hashMap;
        }
        catch (Exception ex){
            return hashMap;
        }
    }

    /**
     * 增加人员
     * @param param
     * @return
     */
    @Override
    public String addUser(UserParams param) throws BusinessException {
        String password=passwordEncoder.encode("admin123.");
        UserEntity userEntity=new UserEntity();
        BeanUtils.copyProperties(param, userEntity);
        userEntity.setState(1);
        userEntity.setRoles("ROLE_ACTIVITI_USER");
        userEntity.setPassword(password);
        userEntity.setGuuid(UUID.randomUUID().toString());

        userEntityMapper.addUser(userEntity);

        //修改岗位信息
        if(param.getPositions().length>0){
            positionEntityMapper.deletePositionUser(param.getUsername());
            for(String position: param.getPositions()){
                userEntityMapper.addUserPosition(UUID.randomUUID().toString(),param.getUsername(),position);
            }
        }
        //修改角色信息
        if(param.getRoles().length>0){
            rolesEntityMapper.deleteRoleUser(param.getUsername());
            for(String role: param.getRoles()){
                userEntityMapper.addUserRoles(UUID.randomUUID().toString(),param.getUsername(),role);
            }
        }

        return "新增成功";
    }

    /**
     * 根据部门编号查找人员
     * @param departid
     * @return
     */
    @Override
    public List<UserEntity> getUserByDepartId(String departid){
        return userEntityMapper.getUserByDepartId(departid);
    }

    /**
     * 修改人员信息
     * @param param
     * @return
     */
    @Override
    public String updateUser(UserParams param){
        UserEntity userEntity=new UserEntity();
        BeanUtils.copyProperties(param, userEntity);
        userEntity.setId(param.getId().longValue());

        if(StringUtils.isNull(param.getGuuid())){
            userEntity.setGuuid(UUID.randomUUID().toString());
            userEntityMapper.addDeptUser(userEntity);
        }
        userEntityMapper.updateUser(userEntity);

        //修改岗位信息
        if(!StringUtils.isNull(param.getPositions())) {
            if (param.getPositions().length > 0) {
                positionEntityMapper.deletePositionUser(param.getUsername());
                for (String position : param.getPositions()) {
                    userEntityMapper.addUserPosition(UUID.randomUUID().toString(), param.getUsername(), position);
                }
            }
        }
        //修改角色信息
        if(!StringUtils.isNull(param.getRoles())) {
            if (param.getRoles().length > 0) {
                rolesEntityMapper.deleteRoleUser(param.getUsername());
                for (String role : param.getRoles()) {
                    userEntityMapper.addUserRoles(UUID.randomUUID().toString(), param.getUsername(), role);
                }
            }
        }
        return "修改成功";
    }

    /**
     * 修改密码
     * @param param
     * @return
     */
    @Override
    public String updatePwd(UserParams param){
        UserInfo userInfo = mapper.getUserInfo(param.getUsername());
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        if(encoder.matches(param.getOldpwd(),userInfo.getPassword())) {
            String newPassword=passwordEncoder.encode(param.getNewpwd());
            userEntityMapper.updatePwd(param.getUsername(),newPassword);
        }
        else{
            return "原密码不正确";
        }
        return "修改成功";
    }

    /**
     * 重置密码
     * @param param
     * @return
     */
    @Override
    public String resetPwd(UserParams param){
        String newPassword=passwordEncoder.encode("admin123.");
        userEntityMapper.updatePwd(param.getUsername(),newPassword);
        return "修改成功";
    }

    /**
     * 删除用户
     * @param userEntity
     * @return
     */
    @Override
    public String deleteUser(UserEntity userEntity){
        userEntityMapper.deleteUser(userEntity);
        return "删除成功";
    }

    /**
     * 获取用户分组列表
     * @param groupEntity
     * @return
     */
    @Override
    public List<GroupEntity> getGroupPage(GroupEntity groupEntity){
        List<GroupEntity> groupEntities=groupMapper.getGroupList(groupEntity.getName());
        return groupEntities;
    }
    /**
     * 获取分组内成员
     * @param groupEntity
     * @return
     */
    @Override
    public List<UserEntity> getUserByGorupId(GroupEntity groupEntity){
        List<UserEntity> userEntities = groupMapper.getUserByGorupId(groupEntity.getId());
        return userEntities;
    }

    /**
     * 增加分组
     * @param groupEntity
     * @return
     */
    @Override
    public String addGroup(GroupEntity groupEntity){
        groupEntity.setId(UUID.randomUUID().toString());
        groupMapper.addGroup(groupEntity);
        return "添加成功";
    }

    /**
     * 更新分组
     * @param groupEntity
     * @return
     */
    @Override
    public String updataGroup(GroupEntity groupEntity){
        groupMapper.updataGroup(groupEntity);
        return "更新成功";
    }

    /**
     * 删除分组
     * @param groupEntity
     * @return
     */
    @Override
    public String deleteGroup(GroupEntity groupEntity){
        groupMapper.deleteGroup(groupEntity.getId());
        return "删除成功";
    }

    /**
     * 增加人员分组
     * @param param
     * @return
     */
    @Override
    public String addUserGroup(GroupUsersParams param){
        List<HashMap<String,Object>> hashMapList=new ArrayList<>();
        HashMap<String,Object> hashMap=new HashMap<>();
        for(UserEntity userEntity:param.getUserDatalist()){
            for (UserEntity user:param.getUserlist()){
                if(userEntity.getUsername().equals(user.getUsername()))
                    continue;
                else{
                    hashMap=new HashMap<>();
                    hashMap.put("id",UUID.randomUUID().toString());
                    hashMap.put("username",user.getUsername());
                    hashMap.put("groupid",param.getGroupid());
                    hashMapList.add(hashMap);
                }
            }
        }
        userGroupMapper.addUserGroup(hashMapList);
        return "新增成功";
    }

    /**
     * 删除分组人员
     * @param param
     * @return
     */
    @Override
    public String deleteUserGroup(GroupUsersParams param){
        userGroupMapper.deleteUserGroup(param.getUsername(),param.getGroupid());
        return "删除成功";
    }

  @Override
  public List<OrgGroupTypeEntity> getAllOrgGroupTypeList() {

      try{
          List<OrgGroupTypeEntity> orgGroupTypeList=orgGroupTypeEntityMapper.getAllOrgGroupTypeList();
          //2、组装树形结构
          List<OrgGroupTypeEntity> newList = orgGroupTypeList.stream()
              .filter(t -> t.getParentId().equals("0") || t.getParentId().isEmpty())
              .map((menu) -> {
                  menu.setChildren(getChildren(menu,orgGroupTypeList));
                  return menu;
              })
              .collect(Collectors.toList());
          return newList;
      }
      catch (Exception ex){
          return new ArrayList<>();
      }
  }

    @Override
    public OrgGroupTypeEntity getOrgGroupTypeById(String id) {
        try{
          return orgGroupTypeEntityMapper.getOrgGroupTypeById(id);
        }
        catch (Exception ex){
            return new OrgGroupTypeEntity();
        }
    }

    @Override
    public String addOrgGroupType(String id, String name, String parentNo) {
        try{
            OrgGroupTypeEntity orgGroupTypeEntity=new OrgGroupTypeEntity();
            orgGroupTypeEntity.setOrgGroupTypeID(id);
            orgGroupTypeEntity.setName(name);
            orgGroupTypeEntity.setParentId(parentNo);
            orgGroupTypeEntityMapper.addOrgGroupType(orgGroupTypeEntity);
            return "执行成功";
        }
        catch (Exception ex){
            return ex.getMessage().toString();
        }
    }

    @Override
    public String deleteOrgGroupTypeById(String id) {
        try{
            orgGroupTypeEntityMapper.deleteOrgGroupTypeById(id);
            return "执行成功";
        }
        catch (Exception ex){
            return ex.getMessage().toString();
        }
    }

    @Override
    public String updateOrgGroupType(String id, String name, String parentNo) {
        try{
            OrgGroupTypeEntity orgGroupTypeEntity=new OrgGroupTypeEntity();
            orgGroupTypeEntity.setOrgGroupTypeID(id);
            orgGroupTypeEntity.setName(name);
            orgGroupTypeEntity.setParentId(parentNo);
            orgGroupTypeEntityMapper.updateOrgGroupType(orgGroupTypeEntity);
            return "执行成功";
        }
        catch (Exception ex){
            return ex.getMessage().toString();
        }
    }

    private List<OrgGroupTypeEntity> getChildren(OrgGroupTypeEntity root, List<OrgGroupTypeEntity> all){
        List<OrgGroupTypeEntity> childrenList = all.stream()
            .filter(t -> t.getParentId().equals(root.getOrgGroupTypeID()) )
            .map(g -> {
                //找子菜单
                g.setChildren(getChildren(g,all));
                return g;
            })
            //菜单排序
            .collect(Collectors.toList());

        return childrenList;
    }



}
